import 'dart:async';

import 'package:web_socket_channel/web_socket_channel.dart';

void main() async {
  final wsUri = Uri.parse('wss://echo.websocket.org/');
  final channel = WebSocketChannel.connect(wsUri);
  await channel.ready;
  channel.stream.listen((message) {
    print("message: $message");
    Timer(
        Duration(
          milliseconds: 500,
        ), () {
      channel.sink.add('received: ${DateTime.now().toIso8601String()}');
    });
  });
}
